package com.gemme.gemme.wode;

import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.RelativeLayout;

import com.alibaba.fastjson.JSON;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.MyLocationStyle;
import com.gemme.gemme.BaseActivity;
import com.gemme.gemme.R;
import com.gemme.gemme.manager.DataManager;
import com.gemme.gemme.util.LocationManager;
import com.gemme.gemme.view.Topview;
import com.gemme.gemme.view.WuliuView;
import com.jaeger.library.StatusBarUtil;

import org.json.JSONObject;

import java.util.HashMap;

import androidx.annotation.RequiresApi;

//侧滑删除地址
public class SeeWuliuActivity extends BaseActivity{

    private Bundle savedInstanceState;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.savedInstanceState = savedInstanceState;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wuliu_see);
        initTop();
        initView();
        initIntentData();
    }

    String courierServicesCode;
    private void initIntentData() {
        try {

            courierServicesCode = getIntent().getStringExtra("courierServicesCode");

            if(!TextUtils.isEmpty(courierServicesCode)){
                getData();
            }

        }catch (Exception e){

        }
    }
    WuliuBean wuliuBean;
    private void getData() {
        String url = DataManager.BaseUrl_panghu + "exp/express/getExpress/" + courierServicesCode;



        HashMap<String, String> headMap = new HashMap<>();
        headMap.put(DataManager.AuthorizationKey,DataManager.getToken(mContext));
        DataManager.toServer2(mContext, url, DataManager.POST_TYPE, "", headMap, new DataManager.GeResponse() {
            @RequiresApi(api = Build.VERSION_CODES.O)
            @Override
            public void onResponse(String response) {
                try {
                    System.out.println("");
                    wuliuBean = JSON.parseObject(response, WuliuBean.class);
                    wuliuView.setData(wuliuBean);
                }catch (Exception e){

                }

            }
        });
    }
    WuliuView wuliuView;
    private void initView() {
        initMapView();

        wuliuView = findViewById(R.id.wuliuView);

    }


    //
    private void initMapView() {
        MapView mapView = findViewById(R.id.mapview);
        mapView.onCreate(savedInstanceState);// 此方法必须重写
        AMap aMap = mapView.getMap();

        MyLocationStyle myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点，定位点依照设备方向旋转，并且会跟随设备移动。（1秒1次定位）如果不设置myLocationType，默认也会执行此种模式。
        myLocationStyle.interval(10000); //设置连续定位模式下的定位间隔，只在连续定位模式下生效，单次定位模式下不会生效。单位为毫秒。
        aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
        //aMap.getUiSettings().setMyLocationButtonEnabled(true);设置默认定位按钮是否显示，非必需设置。
        aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点，false表示隐藏定位蓝点并不进行定位，默认是false。
        aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
        myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW);//连续定位、且将视角移动到地图中心点，定位蓝点跟随设备移动

    }





    private void initTop() {
//        StatusBarUtil.setColor(this,getResources().getColor(R.color.white_color) );
        StatusBarUtil.setTransparent(this);
//        StatusBarUtil.setTranslucent(this,250);
        Topview topview = findViewById(R.id.topview);
        topview.setContentText("订单详情");
    }




}